try:
    import abc_decoder
except:
    import decoders.abc_decoder as abc_decoder

import math, random
import pandas as pd
import numpy as np

def get_class():
    'None 表示这是抽象基类'
    return csv_decoder

class csv_decoder(abc_decoder.abs_decoder):
    def __init__(self):
        self.strFormat = 'npy'
    def get_name(self):
        return 'npy decoder'            
    def decode(self, file_path:str, **kwargs):
        
        try:
            column_keys = kwargs['column_keys']
        except:
            column_keys=['ax', 'ay', 'az']

        print('decoding %s file: %s' % (self.strFormat, file_path))
        npy = np.random.random(30000) * 5
        npy = npy.reshape(-1, 3)
        if (column_keys[0] != 'col1'):
            if (column_keys[1] != 'col2') & (column_keys[2] == 'col3'):
                retNpy = npy[:, 2]
            if (column_keys[1] == 'col2') & (column_keys[2] != 'col3'):
                retNpy = npy[:, 1]
            else:
                retNpy = npy[:, [1, 2]]
        elif (column_keys[1] != 'col1'):
            if (column_keys[0] != 'col2') & (column_keys[2] == 'col3'):
                retNpy = npy[:, 2]
            if (column_keys[0] == 'col2') & (column_keys[2] != 'col3'):
                retNpy = npy[:, 0]
            else:
                retNpy = npy[:, [0, 2]]
        elif (column_keys[2] != 'col1'):
            if (column_keys[0] != 'col2') & (column_keys[1] == 'col3'):
                retNpy = npy[:, 1]
            if (column_keys[0] == 'col2') & (column_keys[1] != 'col3'):
                retNpy = npy[:, 0]
            else:
                retNpy = npy[:, [0, 1]]
        else:
            retNpy = npy
        return retNpy
      